<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class AdminController extends GxController {
    public $cssFile = null;
	public $layout='/layouts/column2';
	
	public function filters() {
		return array(
			'accessControl', 
		);
	}
	
    public function accessRules() {
        return array(
            array('allow',
                'expression' => 'Controller::checkAdmin()',
            ),
            array('deny',
                'users'=>array('*'),
            ),         
        );
    } 	
	
    public function getBaseUrl() {
        return Yii::app()->getBaseUrl(true);
    }
    
    protected function beforeRender($view) {
        if (!is_null($this->cssFile)) {
            Yii::app()->getClientScript()->registerCssFile($this->cssFile);
        }
        return parent::beforeRender($view);
    }
    /*
    public static function checkAdmin() {
    	if (!isset(Yii::app()->user)) return false;
    	if (!isset(Yii::app()->user->usergroup)) return false;
    	return (Yii::app()->user->usergroup == 1);
    }
    */


	public function cleanFileName($name) {
		return str_ireplace(' ', '_',$name);
	}
}